package com.mangaenglish.business.controller;

import com.google.common.collect.Lists;
import com.mangaenglish.common.constant.enums.Book;
import com.mangaenglish.common.dto.request.BookQueryDTO;
import com.mangaenglish.common.dto.response.BookDTO;
import com.mangaenglish.common.dto.response.ChapterDTO;
import com.mangaenglish.common.result.Result;
import com.sun.tracing.dtrace.Attributes;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
 * Created by Administrator on 2018/1/6 0006.
 */
@Api("漫画英语api")
@RestController
public class BookController {

    @ApiOperation("获取书本列表")
    @RequestMapping(value = "/books/query", method = RequestMethod.POST)
    public Result<List<BookDTO>> allCategory(@RequestBody BookQueryDTO bookQueryDTO){
        List books = Lists.newArrayList();
        books.add(BookDTO.builder().bookId("1").bookName("哆唻A梦").bookType(Book.BookType.PRIMARY).build());
        books.add(BookDTO.builder().bookId("2").bookName("七龙珠").bookType(Book.BookType.PRIMARY).build());
        return Result.createSucess(books);
    }

    @RequestMapping(value = "/books/{book_id}", method = RequestMethod.GET)
    public Result<BookDTO> getAllCategory(@PathVariable("book_id") String bookId){
        List<ChapterDTO> chapters = Lists.newArrayList();
        chapters.add(ChapterDTO.builder().categoryId("category_1").categoryName("第一章").build());
        chapters.add(ChapterDTO.builder().categoryId("category_2").categoryName("第二章").build());
        chapters.add(ChapterDTO.builder().categoryId("category_3").categoryName("第三章").build());

        return Result.<BookDTO>createSucess(BookDTO.builder().bookId("1").bookName("哆唻A梦").chapters(chapters).build());
    }


}
